
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.ArrayList;

/** A naive and buggy implementation of a set of strings.
 *  
 * @author Mark Utting  April 2007 for COMP551
 *
 */
public class MySet2 extends AbstractSet<String>
{
	private ArrayList<String> contents = new ArrayList<String>();

	@Override
	public Iterator<String> iterator() {
		return contents.iterator();
	}

	@Override
	public int size() {
		return contents.size();
	}

	@Override
	public boolean add(String e) {
		if (! contents.isEmpty() && contents.get(0).equals(e))
			return false;
		else
			return contents.add(e); // always adds to end
	}
}
